integral of a piecewise function